<?php

declare(strict_types=1);

namespace app\wechat\controller\admin;

use think\Request;
use think\Response;
use sheep\model\Config as SheepConfig;
use sheep\controller\Backend;

class Config extends Backend
{

    /**
     * 公众号配置
     *
     * @return Response
     */
    public function officialAccount(Request $request): Response
    {
        if ('GET' === $request->method()) {

            $configs = SheepConfig::getConfigs('wechat.officialAccount', false);
            $configs['server_url'] = request()->domain() . '/wechat/serve';
        } elseif ('PUT' === $request->method()) {

            $configs = SheepConfig::setConfigs('wechat.officialAccount', $request->param());

        }
        return success('操作成功', $configs);
    }
}
